﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThuVien;
using System.Data;

namespace TranTekBE.NhaThuoc
{
    public partial class DetailsHistoryTrans : PagePopUp
    {
        public string Bill_ID
        {
            get
            {
                return FunctionsUtils.GetValueStringFromQueryString("IDBill", null);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //string a = Bill;

            lbMaBill.Text = Bill_ID;
            GetData();
        }

        private void GetData()
        {
             string sql = string.Format(@"select item.C001203 as MaSP, item.C001204 as TenSP,
                 item.C001215 , unit.C004002 as DVT, line.C003106 as SoLuong, line.C003107 as DonGia, 
                 line.C003102, linediscount.C003302 as CK, line.C003108 as ThanhTien, line.C003116, line.C003117  from T0031 line 
                  Left Join T0012 item on line.C003102 = item.C001200 
                   Left Join T0040 unit on line.C003103 = unit.C004000  
                   Left Join T0033 linediscount on line.C003100 = linediscount.C003305  
                   Where line.C003101 = '{0}' 
                   and item.C001200 is not null ", Bill_ID);
             DataSet ds = FunctionsUtils.Database.ExecuteQuery(sql);
            if(!FunctionsUtils.isDataSetNullOrEmpty(ds))
            {
                //ltError.Text = string.Empty;
                try
                {
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        rpCategory.DataSource = ds;
                        rpCategory.DataBind();
                        ltNoRecord.Visible = false;
                    }
                    else
                    {
                        rpCategory.DataSource = null;
                        rpCategory.DataBind();
                        ltNoRecord.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
        protected void Sort_Click(object sender, EventArgs e)
        {

        }


    }
}